#
# Copyright 2007 Jeffrey Palm
#

package Support;

use LWP::Simple;

sub extractResult {
    my ($url) = @_;
    $lines = get($url);    
    if ($lines =~ m/id="result"[^>]*>([^<]+)</) {
        return $1;
    }
    return 0;
}

sub urldecode {
    my ($theURL) = @_;
    $theURL =~ tr/+/ /;
    $theURL =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
    $theURL =~ s/<!--(.|\n)*-->//g;
    return $theURL;
}

sub urlencode {
    my ($theURL) = @_;
   $theURL =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
   return $theURL;
}

return 1;
